package com.fifth.apartment.service.impl;



import com.fifth.apartment.entity.UserInfo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fifth.apartment.mapper.UserInfoMapper;
import com.fifth.apartment.service.UserInfoService;
import com.fifth.apartment.vo.PageQueryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
* @author liubo
* @description 针对表【user_info(用户信息表)】的数据库操作Service实现
* @createDate 2023-07-26 11:12:39
*/
@Service
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
    implements UserInfoService {
    @Autowired
    private UserInfoMapper userInfoMapper;


    @Override
    public Page<UserInfo> findPage(PageQueryVO vo) {
        Integer currentPage = vo.getCurrentPage();
        Integer pageSize = vo.getPageSize();
        String queryString = vo.getQueryString();
        //封装Page对象
        Page<UserInfo> page = new Page<>(currentPage , pageSize);
        //封装查询条件
        LambdaQueryWrapper<UserInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(StringUtils.hasLength(queryString) , UserInfo::getPhone , queryString)
                .or().like(StringUtils.hasLength(queryString) , UserInfo::getStatus , queryString);
//        lambdaQueryWrapper.eq(StringUtils.hasLength(queryString) , UserInfo::getPhone , queryString)
        //分页查询数据
//        lambdaQueryWrapper.eq(queryVo.getStatus() != null,UserInfo::getStatus,queryVo.getStatus());
        Page<UserInfo> Page = this.baseMapper.selectPage(page, lambdaQueryWrapper);
        return Page;
    }
}




